package com.jiuyuan.controller;

import com.jiuyuan.entity.Department;
import com.jiuyuan.entity.vo.RespBean;
import com.jiuyuan.service.IDepartmentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jiuyuan
 * @since 2023-02-15
 */
@RestController
@RequestMapping("/system/basic/department")
public class DepartmentController {
    @Autowired
    IDepartmentService departmentService;

    @ApiOperation("获取所有部门")
    @GetMapping("/")
    public RespBean list(){
        //使用子循环嵌套
        return RespBean.success(departmentService.allList());
    }

    @ApiOperation("添加部门")
    @PostMapping("/")
    public RespBean add(@RequestBody Department department){
        //使用存储过程
        return departmentService.add(department);
    }

    @ApiOperation("删除部门")
    @DeleteMapping("/{id}")
    public RespBean delete(@PathVariable Integer id){
        //使用存储过程
        return departmentService.delete(id);
    }
}





























